home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 16658 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: mail2news.demon.co.uk!lorelei.demon.co.uk
  2. From: John Croudy <john@lorelei.demon.co.uk>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: goto command
  5. Date: Wed, 10 Apr 96 19:58:43 GMT
  6. Organization: home
  7. Message-ID: <9604101958.AA001q4@lorelei.demon.co.uk>
  8. References: <4k9vne$9lu@nntp.igs.net><4k9vne$9lu@nntp.igs.net> <9604081700.AA001p0@lorelei.demon.co.uk> <4kfuuh$3v8@nic.dataphone.se>
  9. X-NNTP-Posting-Host: lorelei.demon.co.uk
  10. X-Newsreader: TIN [AMIGA 1.3 950726BETA PL0]
  11. X-Mail2News-Path: disperse.demon.co.uk!post.demon.co.uk!lorelei.demon.co.uk
  12.  
  13. On 10 Apr 1996 09:27:45 GMT, Jarmo Paavilainen wrote:
  14.  
  15. > Why ?! goto is great for jumping out of loops !
  16. >
  17. > REDO:
  18. > for(i = 0;i<20;i++)
  19. >  {
  20. >  ...Do something
  21. >  while(x != 3)
  22. >   {
  23. >   ...Do something
  24. >   while(y ==4)
  25. >    {
  26. >    ...Do something
  27. >    if(t == 8)
  28. >     goto DONE;
  29. >    if(t == 9)
  30. >     goto REDO;
  31.  
  32. It may be legal syntax but this is unstructured, difficult to follow,
  33. and makes a program hard to modify.  I haven't used goto in any C or C++
  34. programs that I've written for 1.5 years, therefore I believe it is not
  35. needed.  There's always a better way, although maybe not as FAST.  In
  36. fact, the only reason to use it is for very fast forward jumps out of
  37. deep loops...  but who needs that kind of micro-optimisation these days
  38. anyway?  Better to waste a few microseconds at run time than spend days
  39. trying to untangle spagetti.
  40.  
  41. John
  42. xxxx
  43.